package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Dict;
import com.bw.entity.Zxt;
import com.bw.mapper.JobInfoMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class TuController {

    @Autowired
    JobInfoMapper jobInfoMapper;

    @RequestMapping("/tu.do")
    public String tu(Model model){
      List<Dict> gradeList = jobInfoMapper.listGrade();

        model.addAttribute("gradeList",gradeList);
        return "tu";
    }
    @RequestMapping("/zxt.do")
    @ResponseBody
    public List<Zxt> zxt(Integer gradeId,String remark) {
        List<Zxt> list = jobInfoMapper.zxt(gradeId, remark);
        return list;
    }
    @RequestMapping("/bing.do")
    @ResponseBody
    public List<Bing> bing(Integer gradeId,String remark){
        List<Bing> list = jobInfoMapper.bing(gradeId,remark);

        return list;
    }
    @RequestMapping("/excel.do")
    public void excel(Integer gradeId, String remark, HttpServletResponse response){
        List<Bing> list = jobInfoMapper.bing(gradeId,remark);
        ExcelUtils.exportExcel(list,"职级导出","sheet1",response);
    }
}
